<template>
  <!-- 出入库历史记录 -->
	<div id="record">
    <el-dialog  title="出入库历史记录" :visible.sync="details" width="45%" top="3vh">
      <el-button  @click="record_jin" :type="beij==0?'success':''">入库</el-button>
      <el-button  @click="record_chu" :type="beij==1?'success':''">出库</el-button>
     <el-table :data="dataList" v-loading="loading">
        <el-table-column header-align='center' align='center' prop="createdTime" label="申请时间" ></el-table-column>
        <el-table-column header-align='center' align='center' prop="doneTime" label="成功时间" ></el-table-column>
         <el-table-column header-align='center' align='center' prop="" label="记录类型" >
           <template slot-scope="scope">{{beij==0?'入库':'出库'}}</template>
         </el-table-column>
        <el-table-column header-align='center' align='center' prop="amount" label="数量" ></el-table-column>
        <el-table-column header-align='center' align='center' prop="username" label="申请人" ></el-table-column>
      </el-table>
      <el-pagination style=' margin-top:35px;width:100%;text-align: center;' v-show="totals>sizec" :page-size="sizec" :total="totals" :page-sizes="ye_s"
         background @size-change="handleSizeChange" @current-change="handleCurrentChange"layout="total, slot, sizes, prev, pager, next, jumper">
      </el-pagination>
    </el-dialog>
  </div>
</template>

<script>
  import {recordStock} from '@/api_bast/stock.js'
	export default {
		name: '',
		data(){
			return{
				loading:false,
				details: false,
				dataList:[],
				totals: 0, //总条数
				page: 1,
				sizec: 10,
				ye_s: [10,20],
				sku: "",
        beij: 0
			}
		},
    props: {},
		components:{},
    methods:{
      qf(){ //取反，active等于自己的相反数
        return this.details = !this.details
      },
      record_jin(){//获取入库数据
        this.dataList = [];
        this.loading=true;
        this.beij = 0
        recordStock(this.sku).then(res=>{
          console.log(res)
          this.totals = res.resData.in.total;
          this.dataList = res.resData.in.list
          this.loading=false;
        })
      },
      record_chu(){//获取出库数据
        this.dataList = [];
        this.loading=true;
        this.beij = 1
        recordStock(this.sku).then(res=>{
          console.log(res)
          this.totals = res.resData.out.total;
          this.dataList = res.resData.out.list
          this.loading=false;
        })
      },
      handleSizeChange(val){//每页条数改变时触发
          this.sizec = val;
          if(this.beij==0){
            this.record_jin()
          }else{
            this.record_chu()
          }
      },
      handleCurrentChange(val){//当前页改变时触发
          this.page = val
        if(this.beij==0){
          this.record_jin()
        }else{
          this.record_chu()
        }
      }
    }
	}
</script>

<style scoped="scoped">

</style>
